//
//  BCFileExploreConfig.m
//  Pods
//
//  Created by Basic on 2017/3/16.
//
//

#import "BCFileExploreConfig.h"
#import "BCDebugDirectoryBrowserPage.h"
#import "BCDebugUtils.h"
#import "BCDebugCom.h"

@interface BCFileExploreConfig()

@end

@implementation BCFileExploreConfig
#pragma mark - system
- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}
-(void)dealloc
{
    
}



#pragma mark -  BCDebugKitProtocol
-(BCDebugItemGroup *)bcDebugConfigSetupDebugGroup
{
    BCDebugItemGroup *debugGroup = [BCDebugItemGroup new];
    debugGroup.bcName = @"文件管理";
    debugGroup.bcConfigClass = [self class];
    
    //APP目录
    BCDebugItemModel *itemCurrnt = [BCDebugItemModel new];
    itemCurrnt.bcName = @"APP目录";
    itemCurrnt.bcAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
//    __weak typeof(self) weakSelf = self;
    [itemCurrnt setSelectItemAction:^(BCDebugItemModel *item, NSInteger selectRow){
        NSString *homePath = NSHomeDirectory();
        [BCFileExploreConfig pushDirectoryBrowser:homePath title:@"APP目录"];
        
    }];
    [debugGroup.bcItems addObject:itemCurrnt];
    
    
    //越狱系统根 目录
    if ([BCDebugUtils deviceJailBroken]) {
        BCDebugItemModel *itemCurrnt2 = [BCDebugItemModel new];
        itemCurrnt2.bcName = @"系统根目录";
        itemCurrnt2.bcAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [itemCurrnt2 setSelectItemAction:^(BCDebugItemModel *item, NSInteger selectRow){
            [BCFileExploreConfig pushDirectoryBrowser:@"/" title:@"系统根目录"];
            
        }];
        [debugGroup.bcItems addObject:itemCurrnt2];
    }
    
    
    //app 目录
    NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
    NSString *appName = [bundlePath lastPathComponent];
    BCDebugItemModel *itemCurrnt1 = [BCDebugItemModel new];
    itemCurrnt1.bcName = @"安装包";
    itemCurrnt1.bcAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
    [itemCurrnt1 setSelectItemAction:^(BCDebugItemModel *item, NSInteger selectRow){
        [BCFileExploreConfig pushDirectoryBrowser:bundlePath title:appName];
    }];
    [debugGroup.bcItems addObject:itemCurrnt1];
    return debugGroup;
}

#pragma mark - 跳转
+ (void)pushDirectoryBrowser:(NSString *)path title:(NSString *)title
{
    BCDebugDirectoryBrowserPage *vc = [[BCDebugDirectoryBrowserPage alloc] initWithPath:path];
    vc.bctitle = title;
    [[BCDebugCom sharedInstance].rootNavcDebug pushViewController:vc animated:YES];
//    viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
}

+ (void)pushTextEditViewControllerWithViewController:(UIViewController *)viewController path:(NSString *)path {
//    viewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
//    
//    BCDebugTextEditPage *vc = [[BCDebugTextEditPage alloc] initWithFilePath:path];
//    [viewController.navigationController pushViewController:vc animated:YES];
}



@end
